﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Microsoft.Office.Core;
using WpfControlLibrary;
using System.Windows;

namespace FirstWordAddIn
{
    public partial class ThisAddIn
    {

        private CustomTaskPaneControl myUserControl1;
        private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            myUserControl1 = new CustomTaskPaneControl();
            myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "汇演");
            myCustomTaskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
            myCustomTaskPane.Width = 400;
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        public void showTaskPane(PageType pageType)
        {
            if (!myCustomTaskPane.Visible)
            {
                myCustomTaskPane.Visible = true;
            }

            myUserControl1.ShowPage(pageType);
        }

        void Application_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
        {
            Doc.Paragraphs[1].Range.InsertParagraphBefore();
            Doc.Paragraphs[1].Range.Text = "This  text was added by using code.";
        }


        #region VSTO 生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }

        #endregion
    }
}
